// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "Engine/DataTable.h"
#include "Messaging/CommonGameDialog.h"

#include "Messaging/CommonMessagingSubsystem.h"
#include "LyraConfirmationScreen.generated.h"

class IWidgetCompilerLog;

class UCommonTextBlock;
class UCommonRichTextBlock;
class UDynamicEntryBox;
class UCommonBorder;

/**
 * Lyra确认屏幕类，用于显示确认对话框
 */
UCLASS(Abstract, BlueprintType, Blueprintable)
class ULyraConfirmationScreen : public UCommonGameDialog
{
	GENERATED_BODY()
public:
	/**
	 * 设置对话框内容
	 * @param Descriptor 对话框描述符，包含标题、内容、按钮动作等信息
	 * @param ResultCallback 结果回调委托
	 */
	virtual void SetupDialog(UCommonGameDialogDescriptor* Descriptor, FCommonMessagingResultDelegate ResultCallback) override;
	/** 关闭并销毁对话框 */
	virtual void KillDialog() override;

protected:
	/** 本地初始化完成时调用 */
	virtual void NativeOnInitialized() override;
	/**
	 * 关闭确认窗口
	 * @param Result 关闭结果
	 */
	virtual void CloseConfirmationWindow(ECommonMessagingResult Result);

#if WITH_EDITOR
	/**
	 * 验证编译时的默认值
	 * @param CompileLog 编译器日志接口
	 */
	virtual void ValidateCompiledDefaults(IWidgetCompilerLog& CompileLog) const override;
#endif

private:

	/**
	 * 处理点击关闭区域的鼠标按钮按下事件
	 * @param MyGeometry 控件几何信息
	 * @param MouseEvent 鼠标事件
	 * @return 事件回复
	 */
	UFUNCTION()
	FEventReply HandleTapToCloseZoneMouseButtonDown(FGeometry MyGeometry, const FPointerEvent& MouseEvent);

	FCommonMessagingResultDelegate OnResultCallback; //结果回调委托

private:
	UPROPERTY(Meta = (BindWidget))
	TObjectPtr<UCommonTextBlock> Text_Title; //标题文本控件

	UPROPERTY(Meta = (BindWidget))
	TObjectPtr<UCommonRichTextBlock> RichText_Description; //描述富文本控件

	UPROPERTY(Meta = (BindWidget))
	TObjectPtr<UDynamicEntryBox> EntryBox_Buttons; //按钮动态入口框

	UPROPERTY(Meta = (BindWidget))
	TObjectPtr<UCommonBorder> Border_TapToCloseZone; //点击关闭区域边框

	UPROPERTY(EditDefaultsOnly, meta = (RowType = "/Script/CommonUI.CommonInputActionDataBase"))
	FDataTableRowHandle CancelAction; //取消动作的数据表行句柄
};